<!DOCTYPE html>
<html style="height: 100%">
<head>
    <meta charset="utf-8">
    <title>Redis Client [SubMain]</title>
</head>
<body style="height: 100%; overflow: hidden;"> <!-- 可拖拽 -->
<div id="app"></div>
</body>

<script>
    'use strict';
    import Vue from 'vue/dist/vue.js';
    import axios from 'axios';
    import $ from 'jquery';
    import {remote, ipcRenderer} from 'electron';
    import App from './components/SubMain.vue';
    import router from './routes';
    import i18n from './common/i18n';
    // import VueCodeMirror from 'vue-codemirror'

    import iView from 'iview';

    const currentWindow = remote.getCurrentWindow();

    Vue.use(iView);
    // Vue.use(VueCodeMirror);
    // const ipc = electron.ipcRenderer;

    if (!process.env.IS_WEB) Vue.use(require('vue-electron'));

    axios.defaults.withCredentials = true;
    Vue.axios = Vue.prototype.$axios = axios;
    Vue.$ = Vue.prototype.$ = $;
    Vue.config.productionTip = false;
    Vue.i18n = Vue.prototype.i18n = i18n.getLang(window.localStorage.getItem('lang'));

    //拦截器
    axios.interceptors.response.use((response) => {
        return response;
    }, (error) => {
        console.log(error);
        if (error.response && error.response.status === 401) {
//            router.push({path: '/login'});
        }
    });

    ipcRenderer.on('createRedisConnection', (event, message) => {
        $("title").html("Redis Client [" + message + "]");
    });

    // if (!rds.client) {
    //     new Promise(function (resolve, reject) {
    //         console.log("开始创建Redis连接！");
    //         resolve(rds.connect(currentWindow.redisAlias));
    //         // resolve(rds.redis);
    //     }).then(function (redis) {
    //         console.log(redis);
    //         Vue.redis = Vue.prototype.redis = redis;
    //     }).catch(function (error) {
    //         console.error(error);
    //     });
    // } else {
    //     console.log("Redis连接已存在！");
    //     console.log(rds.redis);
    // }

    /* eslint-disable no-new */
    new Vue({
        components: {App},
        router,
        template: '<App/>'
    }).$mount('#app');
</script>
</html>
